package com.fire.social.mapper;

import com.fire.social.entity.node.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RecommendMapper extends Neo4jRepository<User, Long> {

    @Query(value = "match (user:User) where user.account=$account match ((user)-[:Follow]->()-[:Follow]->(p)) return distinct p")
    List<User> byFriend(@Param("account") String account);

    @Query(value = "match (user:User) where user.account=$account\n" +
            "match (user)-[:Like]->(hobbies)\n" +
            "match (users)-[:Like]->(hobbies) return users")
    List<User> byHobby(@Param("account") String accounte);

    @Query(value = "match (user:User) where user.account=$account\n" +
            "match (user)-[:Publish]->(contents)\n" +
            "match (contents)-[:Praised]->(users) return users")
    List<User> bycontent(@Param("account")String accounte);

}
